package com.boolib.http.core.util;

import com.boolib.http.core.defaults.DefaultHandler;
import com.boolib.http.core.defaults.DefaultHttpChain;
import com.boolib.http.core.face.handler.RequestHandler;
import com.boolib.http.core.util.SpringUtil;
import org.springframework.boot.web.servlet.FilterRegistrationBean;


import javax.servlet.Filter;

/**
 * @author wfq
 */

public class FilterInit  {


    private static  DefaultHttpChain defaultHttpChain = new DefaultHttpChain();

    static {
        DefaultHandler defaultHandler = new DefaultHandler();
        defaultHttpChain.add(defaultHandler);
    }


    public static void add(RequestHandler requestHandler){
        defaultHttpChain.add(requestHandler);
    }

    public static void initFilterRegisterBean(){
        FilterRegistrationBean<Filter> filterFilterRegistrationBean = new FilterRegistrationBean<>();
        filterFilterRegistrationBean.setFilter(defaultHttpChain);
        filterFilterRegistrationBean.addUrlPatterns("/*");
        SpringUtil.registerFilterBean("filterFilterRegistrationBean",filterFilterRegistrationBean);
        Object filterFilterRegistrationBean1 = SpringUtil.getBean("filterFilterRegistrationBean");

    }


}
